﻿<KCtl:BaseUserControl x:Class="Kiva7.Pages.FriendsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                      xmlns:KCtl="clr-namespace:Kiva7.Controls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480"
    KCtl:TiltEffect.IsTiltEnabled="True">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ListBox Grid.Row="0"
            x:Name="lbxLenders" Margin="0,0,-12,0" ItemsSource="{Binding Data}" 
              Background="{StaticResource KivaBackgroundBrush}"
             HorizontalContentAlignment="Stretch" SelectionChanged="lbxLenders_SelectionChanged"
             Visibility="{Binding IsLoaded, Converter={StaticResource booleanToVisibility}}">

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Margin="12,0,0,18"  Orientation="Horizontal">
                        <StackPanel Style="{StaticResource KivaListItemImageStyle}">
                            <KCtl:KivaImageControl x:Name="imgLender" ImageSize="Small" ImageData="{Binding Image}" 
                               Width="78" Height="78" Margin="0,10,0,0"
                            Visibility="{Binding Image, Converter={StaticResource objectVisibility}}" VerticalAlignment="Top" />
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Width="280" Margin="6,0,0,0" Style="{StaticResource KivaListItemStyle}">

                            <TextBlock Text="{Binding Name}" TextWrapping="Wrap" 
                               Style="{StaticResource KivaTextGroupHeaderStyle}" />

                            <TextBlock Text="{Binding WhereAbouts}" TextWrapping="Wrap" 
                               Style="{StaticResource KivaTextNormalStyle}" />

                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding L.Loans, Source={StaticResource L}}" TextWrapping="Wrap" 
                                        Style="{StaticResource KivaTextAccentStyle}" />

                                <TextBlock Text="{Binding LoanCount}" TextWrapping="Wrap" 
                                        Style="{StaticResource KivaTextAccentStyle}" />

                                <TextBlock Text="{Binding L.Invitees, Source={StaticResource L}}" TextWrapping="Wrap" 
                                        Style="{StaticResource KivaTextAccentStyle}" 
                                               Visibility="{Binding InviteeCount, Converter={StaticResource numberVisibility}}"/>

                                <TextBlock Text="{Binding InviteeCount}"  TextWrapping="Wrap" 
                                        Style="{StaticResource KivaTextAccentStyle}" 
                                               Visibility="{Binding InviteeCount, Converter={StaticResource numberVisibility}}"/>

                            </StackPanel>

                        </StackPanel>
                        <Button Click="Button_Click" Width="120" Height="78" BorderThickness="0" >
                            <Grid>
                                <Ellipse Width="40" Height="40" Stroke="White" StrokeThickness="3" />
                                <Image Source="/Images/appbar.edit.rest.png" />
                            </Grid>
                        </Button>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Button Grid.Row="1"
            Click="AddFriendClick"
                Style="{StaticResource KivaButtonStyle}"
                Visibility="{Binding Friends.Count, Converter={StaticResource numberNotVisibility}}" HorizontalAlignment="Stretch" VerticalAlignment="Center">

            <TextBlock Text="{Binding Path=L.ClickHereToAddFriends, Source={StaticResource L}}" 
                           TextAlignment="Center"
                           TextWrapping="Wrap"  
                           Style="{StaticResource KivaButtonTextStyle}"/>

        </Button>

    </Grid>
</KCtl:BaseUserControl>
